home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / News / Alexandra.0.82 / Source / Info.subproj / NiftyView.m < prev    next >
Encoding:
Text File  |  1996-01-30  |  1.8 KB  |  78 lines

  1.  
  2. #import "NiftyView.h"
  3. #import "Sequence.h"
  4.  
  5. @implementation NiftyView
  6.  
  7. //-----------------------------------------------------------
  8. //    INITIALISATION 
  9. //-----------------------------------------------------------
  10.  
  11. - initFrame:(const NXRect *)aFrame;
  12.     {
  13.     NXPoint locations[3]={{116,206},{116,206},{62,169}};
  14.     int        lengths[3]={6,7,5};
  15.     BOOL    bounce[3]={NO,NO,YES};
  16.     NXImage    *image;
  17.     Sequence *seq;
  18.     char    name[16];
  19.     int        i;
  20.     
  21.     [super initFrame:aFrame];
  22.     background=[NXImage findImageNamed:"it"];
  23.     sequences=[[List allocFromZone:[self zone]] init];
  24.     for(i=0;;i++)
  25.         {
  26.         sprintf(name,"Part-%d",i+1);
  27.         image=[NXImage findImageNamed:name];
  28.         if(!image)
  29.             break;
  30.         seq=[[Sequence allocFromZone:[self zone]] init];
  31.         [seq setFrameCount:lengths[i]];
  32.         [seq setLocation:&locations[i]];
  33.         [seq setBounce:bounce[i]];
  34.         [seq setImage:image];
  35.         [sequences addObject:seq];
  36.         }
  37.     return self;
  38.     }
  39.  
  40.  
  41. //-----------------------------------------------------------
  42. //    DRAW BACKGROUND
  43. //-----------------------------------------------------------
  44.  
  45. - drawSelf:(const NXRect *)rects :(int)rectCount;
  46.     {
  47.     NXPoint    zero={0,0};
  48.     
  49.     [background composite:NX_COPY toPoint:&zero];
  50.     return self;
  51.     }
  52.  
  53.  
  54. //-----------------------------------------------------------
  55. //    RUN A SEQUENCE 
  56. //-----------------------------------------------------------
  57.  
  58. - start:sender;
  59.     {
  60.     if([sender isKindOf:[Button class]])
  61.         [[sequences objectAt:[sender tag]] start:self];
  62.     else
  63.         {
  64.         [[sequences objectAt:random()%[sequences count]] start:self];
  65.         if([[self window] isVisible])
  66.             [self perform:@selector(start:) with:sender
  67.                 afterDelay:random()%5000+7000 cancelPrevious:NO];
  68.         }
  69.     return self;
  70.     }
  71.  
  72.  
  73. //-----------------------------------------------------------
  74. //    THAT'S IT 
  75. //-----------------------------------------------------------
  76.  
  77. @end
  78.